package tsb.trinhnx.tree;

import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class FileTree implements Tree<File>{

	/**
	 * 
	 */
	private static final long serialVersionUID = -2749407169294204485L;

	@Override
	public List<File> getRoots() {
		return Arrays.asList(File.listRoots());
	}

	@Override
	public File getParent(File node) {
		return node.getParentFile();
	}

	@Override
	public List<File> getChildren(File node) {
		if(node == null) return getRoots();
		File[] children = node.listFiles();
		return children == null ? new ArrayList<File>() : Arrays.asList(children);
	}

}
